@page "{categoryId?}"
@using FytSoa.Application.Exam
@using FytSoa.Application.Exam.Param
@using FytSoa.Application.Sys
@using FytSoa.Application.Sys.Param
@using FytSoa.Common.Param
@inject SysCodeService _codeService
@inject ExamKnowledgeCategoryService _categoryService
@inject ExamKnowledgeService _knowledgeService
@{
    ViewData["Title"] = "知识库";
    ViewData["Nav"] = 5;
    var paramId = RouteData.Values["categoryId"]?.ToString();
    long categoryId = 0;
    if (!string.IsNullOrEmpty(paramId))
    {
        categoryId = long.Parse(paramId);
    }
    var codeList = await _codeService.GetListAsync(new CodePageParam(){ TypeCode = "grand"});
    var categoryList = await _categoryService.GetListAsync(new WhereParam());
    var knowledgeList = await _knowledgeService.GetPagesAsync(new ExamKnowledgeParam() { Limit = 12,CategoryId = categoryId});
}
<div class="main_content_inner">
        <div class="section-small">

            <div uk-grid>
                <div class="uk-width-1-4@m">
                    <nav class="knowledge-category style-3 setting-menu uk-sticky"
                         uk-sticky="top:30 ; offset:100; media:@@m ;bottom:true; animation: uk-animation-slide-top">
                        <h4 class="mb-0 p-3 uk-visible@m"> 分类</h4>
                        <ul class="uk-nav-primary uk-nav-parent-icon" uk-nav="multiple: true">
                            @{
                                foreach (var item in codeList)
                                {
                                    <li class="uk-parent uk-open">
                                        <a href="javascript:void(0)">@Html.Raw(item.Name)</a>
                                        <ul class="uk-nav-sub">
                                            @{
                                                foreach (var row in categoryList.Where(m=>m.GradeId==item.Id))
                                                {
                                                    <li>
                                                        <a href="/knowledge/@row.Id">@Html.Raw(row.Name)</a>
                                                    </li>
                                                }
                                            }
                                            
                                        </ul>
                                    </li>
                                }
                            }
                            
                        </ul>
                    </nav>
                </div>
                <div class="uk-width-3-4@m">
                    <div class="uk-child-width-1-3@m" uk-grid
                         uk-scrollspy="target: > div; cls: uk-animation-slide-bottom-small; delay: 100">
                        @{
                            foreach (var item in knowledgeList.Items)
                            {
                                <div class="know-item">
                                    <div>
                                        <a href="@item.Document.UrlReplace()" target="_blank" title="@Html.Raw(item.Title)">
                                            <div class="cover"><img src="@item.Cover.UrlReplace()" alt="@Html.Raw(item.Title)"></div>
                                            <div class="title">@Html.Raw(item.Title)</div>
                                            <div class="tag"><span>@Html.Raw(item.Category.Name)</span><span>@Html.Raw(item.GrandCode.Name)</span></div>
                                        </a></div>
                                </div>
                            }
                        
                        }
                    </div>
                    @{
                        if (knowledgeList.Items.Count==0)
                        {
                            <div class="empty"><img src="/assets/images/empty.png" alt="" /><p>暂无数据</p></div>
                        }
                    }
                </div>
            </div>
        </div>
    </div>